(use-package eshell
  :hook
  (eshell-mode . qrthi/eshell-bindings)
  :bind
  (:prefix-map qrthi/shell-prefix
	       :prefix "C-c t"
	       ("e" . eshell))
  :init
  (defalias 'eshell/ff 'find-file)
  (defalias 'eshell/x 'eshell-life-is-too-much)
  (defun eshell/d (&optional file) (dired file))
  (defun qrthi/eshell-bindings ()
    (local-set-key (kbd "C-d") 'ha/eshell-quit-or-delete-char)
    ;; (local-set-key (kbd "C-c C-s") 'helm-eshell-prompts-all)
    (local-set-key (kbd "M-a") 'eshell-previous-prompt)
    (local-set-key (kbd "M-e") 'eshell-next-prompt)
    ;; (local-set-key (kbd "C-g") 'eshell-interrupt-process)
    )
  (defun ha/eshell-quit-or-delete-char (char)
    "Quit eshell or delete character"
    (interactive "p")
    (if (and (eolp) (looking-back eshell-prompt-regexp nil))
	(progn
	  (eshell-life-is-too-much))
      (hungry-delete-forward char)))	;sp-delete-char or alias
  :custom
  ;; (eshell-directory-name (expand-file-name "eshell" no-littering-var-directory))
  ;; (eshell-aliases-file (expand-file-name "aliases" eshell-directory-name))
  ;; (ffap-shell-prompt-regexp nil)
  (eshell-buffer-maximum-lines 100)
  (eshell-cmpl-cycle-completions nil)
  (eshell-destroy-buffer-when-process-dies t)
  (eshell-error-if-no-glob t)
  (eshell-hist-ignoredups t)
  (eshell-history-size 1024)
  (eshell-list-files-after-cd t)
  (eshell-plain-echo-behavior t)
  (eshell-prefer-lisp-functions nil)
  (eshell-prefer-lisp-variables nil)
  (eshell-save-history-on-exit t)
  (eshell-visual-commands '("aria2c" "megadl"))
  ;; :config
  ;; (add-to-list eshell-modules-list)
  )
